
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="{% static 'bootstrap5/bootstrap.min.css' %}">
    <script src="{% static 'bootstrap5/popper.min.js' %}"></script>
    <script src="{% static 'bootstrap5/bootstrap.min.js' %}"></script>
    <link rel="stylesheet" href="{% static 'css/base.css' %}">
    <link rel="stylesheet" href="{% static 'wangeditor/style.css' %}">
    <script src="{% static 'jquery/jquery-3.7.1.min.js' %}"></script>
    <style>
        #editor—wrapper {
            border: 1px solid #ccc;
            z-index: 100; /* 按需定义 */
        }
        #toolbar-container { border-bottom: 1px solid #ccc; }
        #editor-container { height: 500px; }
    </style>
</head>
<body>
<header>
    <div class="px-3 py-2 text-bg-dark">
        <div class="container">
            <div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
                <a href="/" class="d-flex align-items-center my-2 my-lg-0 me-lg-auto text-white text-decoration-none">
                    <svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap"><use href="#bootstrap"></use></svg>
                </a>

                <ul class="nav col-12 col-lg-auto my-2 justify-content-center my-md-0 text-small">
                    <li>
                        <a href="/index" class="nav-link text-white">
                            <svg class="bi d-block mx-auto mb-1" width="24" height="24"><use  href="#speedometer2"></use></svg>
                            主页
                        </a>
                    </li>
                    <li>
                        <a href="#" class="nav-link text-secondary">
                            <svg class="bi d-block mx-auto mb-1" width="24" height="24"><use  href="#home"></use></svg>
                            检测记录
                        </a>
                    </li>
                    <li>
                        <a href="#" class="nav-link text-white">
                            <svg class="bi d-block mx-auto mb-1" width="24" height="24"><use  href="#table"></use></svg>
                            智能助手
                        </a>
                    </li>
                    <li>
                        <a href="#" class="nav-link text-white">
                            <svg class="bi d-block mx-auto mb-1" width="24" height="24"><use  href="black"></use></svg>
                            黑白名单
                        </a>
                    </li>
                    <li>
                        <a href="#" class="nav-link text-white">
                            <svg class="bi d-block mx-auto mb-1" width="24" height="24"><use  href="#people-circle"></use></svg>
                            模型信息
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div class="px-3 py-2 border-bottom mb-3">
        <div class="container d-flex flex-wrap justify-content-center">
            <form class="col-12 col-lg-auto mb-2 mb-lg-0 me-lg-auto" role="search">
                <input type="search" class="form-control" placeholder="Search..." aria-label="Search">
            </form>

            <div class="text-end">
                <button type="button" class="btn btn-light text-dark me-2">Login</button>
                <button type="button" class="btn btn-primary">Sign-up</button>
            </div>
        </div>
    </div>
</header>
<main class="container bg-white p-3 rounded">
    <h1>导入APK信息</h1>
    <div class="mt-3">
        <form method="POST" id="apkinfoform">
            <div class="mb-3">
                <label class="form-label">包名</label>
                <input type="text" name="package" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">名称</label>
                <input type="text" name="app_name" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">版本号</label>
                <input type="text" name="version_name" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">数值版本号</label>
                <input type="text" name="version_code" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">APK大小</label>
                <input type="text" name="apk_size" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">开发者（通常是颁发者）</label>
                <input type="text" name="issuer" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">MD-5 签名</label>
                <input type="text" name="md5" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">SHA-1 签名</label>
                <input type="text" name="sha1" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">SHA-256 签名</label>
                <input type="text" name="sha256" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">证书有效期</label>
                <input type="text" name="validity_period" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">签名算法</label>
                <input type="text" name="signature_algo" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">哈希算法</label>
                <input type="text" name="hash_algo" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">序列号</label>
                <input type="text" name="serial_number" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">证书内容(DER 编码)</label>
                <input type="text" name="contents_der" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">解压后大小</label>
                <input type="text" name="folder_size" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">图标</label>
                <input type="text" name="icon_url" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">意图</label>
                <input type="text" name="intent" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">活动</label>
                <input type="text" name="activities" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">权限</label>
                <input type="text" name="permissions" class="form-control">
            </div>
            <div class="mb-3">
                <label class="form-label">是否涉诈</label>
                <input type="text" name="ret" class="form-control">
            </div>
            <div class="mb-3 text-end">
                <button class="btn btn-primary" id="apkinfobtn">确定</button>
            </div>
        </form>
    </div>
</main>

<script>
    $(document).ready(function() {
        $("#apkinfobtn").click(function(event) {
            event.preventDefault(); // 阻止表单默认提交行为

            // 获取表单数据
            let formData = $("#apkinfoform").serialize();

            // 发送AJAX请求到Django视图
            $.ajax({
                url: "/blacklist/input_apkinfo", // 这里替换为你的Django视图URL名称
                type: "POST", // 或者根据实际情况使用"GET"
                data: formData,
                dataType: "json", // 期望从服务器接收的数据类型
                success: function(response) {
                    // 请求成功后的处理
                    let apk_id=result["data"]["apk_id"]
                    window.location='/apk_detail/'+apk_id
                    alert("成功：" + response.message);
                },
                error: function(xhr, status, error) {
                    // 请求失败的处理
                    alert("失败：" + error);
                },
                headers: {
                    "X-CSRFToken": "{{ csrf_token }}" // 如果需要的话，包含Django的CSRF令牌
                }
            });
        });
    });
</script>

</body>
</html>